﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Common;
using Business;

namespace WinUI.Frm_MasterPlan
{
    public partial class Frm_ViewMasterPlan : Form
    {
        #region Khai báo biến thành viên
        private string _messageSystemError = String.Empty;
        private List<ComboItem> listEmployeeForCombo;
        private List<ComboItem> listStatusForCombo;
        #endregion

        public Frm_ViewMasterPlan()
        {
            InitializeComponent();
        }

        private void Frm_ViewMasterPlan_Load(object sender, EventArgs e)
        {
            //init CS combo list
            listEmployeeForCombo = new List<ComboItem>();
            listStatusForCombo = new List<ComboItem>();
            //get CS data for combo
            Employee.GetEmployeeByJobForCombo(ref listEmployeeForCombo, "CS");
            CodeDetail.GetStatusForCombo(ref listStatusForCombo);
            //set columnedit for combo
            rI_ccb_CS.DataSource = listEmployeeForCombo;
            rI_ccb_CS.DisplayMember = "Text";
            rI_ccb_CS.ValueMember = "Value";
            rI_slu_Status.DataSource = listStatusForCombo;
            rI_slu_Status.DisplayMember = "Text";
            rI_slu_Status.ValueMember = "ID";
            //show projects by userid
            BindingDataToGrvGameResult();
        }

        //show projects by user id
        private void BindingDataToGrvGameResult()
        {
            List<Business.MyProject> listProject = new List<Business.MyProject>();
            Common.ERROR_CODE.ERROR_CODE_ITEMS_SELECT errCode = Business.Project.GetProjectByUserID(ref _messageSystemError, ref listProject, Global._UserInfo);
            gridControl.DataSource = listProject;
        }

        private void mainTableLayoutPanel_Paint(object sender, PaintEventArgs e)
        {

        }

        private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int row = gridView.FocusedRowHandle;
            int projectID = int.Parse(gridView.GetRowCellValue(row, "ID").ToString());
            string mpName = gridView.GetRowCellValue(row, "ProjectName").ToString();
            
            DialogResult r = MessageBox.Show("Bạn muốn chỉnh sửa Master Plan " + mpName + "?", MESSAGE_TITLE.CONFIRM, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            if (r == System.Windows.Forms.DialogResult.Yes)
            {
                    Form frm = new Frm_CreateMasterPlan(projectID);
                    frm.MdiParent = this.ParentForm;
                    frm.Show();
            }
        }
    }
}
